package com.geektime.hello;

import com.alibaba.fastjson.JSON;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author DRevelation
 * @Date 2020-07-23 上午 10:48
 * @Desc
 */
public class ListDemo {
    public static void main(String[] args) {
        List<Animal> animals = new ArrayList<>();
        Dog dog = new Dog();
        dog.setName("animal");
        dog.setDogName("dog");
        Cat cat = new Cat();
        cat.setName("animal");
        cat.setCatName("cat");
        animals.add(dog);
        animals.add(cat);
        System.out.println(JSON.toJSONString(animals));
    }
}


@Data
class Animal {
    private String name;
}

@EqualsAndHashCode(callSuper = true)
@Data
class Dog extends Animal {
    private String dogName;
}

@EqualsAndHashCode(callSuper = true)
@Data
class Cat extends Animal {
    private String catName;
}